<?
    final class Principio_View_Helper_Types extends Zend_View_Helper_Abstract
    {
        public function types($expand = null)
        {
            $html = "";

            $types = ((!is_null($expand)) && (isset($expand['type_collection']))) ? $expand['type_collection'] : $this->view->model_company->getTypeInCompanyCollection(); //type_in_company_collection;
            $model_company = ((!is_null($expand)) && (isset($expand['model_company']))) ? $expand['model_company'] : $this->view->model_company;

            foreach ($types as $model_type_in_company)
            {
                $is_expand = (!is_null($expand)) && (isset($expand['id'])) && ($expand['id'] == $model_type_in_company->getModelType()->getID());

                $html .= "<li class=\"has_content\"><div class=\"node_pict ".($is_expand ? "opened" : "closed")."\" id=\"company_".$model_company->getID()."_type_".$model_type_in_company->getModelType()->getID()."\"";
                $html .= "onClick=\"expandMenu({id: 0, controller: 'viewbycompany', company_id: ".$model_company->getID().", type_id: ".$model_type_in_company->getModelType()->getID().", level: EXPAND_VIEW_BY_COMPANY_IN_TYPE});\"></div>";
                $html .= "<a href=\"\" onClick=\"ajaxTypes({id: ".$model_type_in_company->getModelType()->getID().", company_id: ".$model_company->getID().", action: 'short', use_inner: true, no_apply: true}); return false;\"><nobr>";
                $html .= $model_type_in_company->getModelType()->getCaption()."</nobr></a>";
                $html .= "<ul id=\"company_".$model_company->getID()."_type_".$model_type_in_company->getModelType()->getID()."_content\" ".($is_expand ? "style=\"display: block;\"" : "").">";
                if ($is_expand)
                    $html .= $expand['expand'];
                $html .= "</ul></li>";
            };

            $html .= "<li class=\"add_item\"><a href=\"\" onClick=\"addItem({menu: 'device', container: 'inner', company_id: ".$model_company->getID()."}); return false;\">Add new device</a></li>";

            return $html;
        }
    };
?>